/**
 * Created by zyy on 15/9/8.
 * zhangyuyu@superjia.com
 */
(function ($) {
    'use strict';

    var Router = App.common.Router;
    var prd = App.modules.prd;

    var router = new Router({
        root: '/api',
        routes: {
            '': 'init',
            '/': 'init',
            '/project/:id': 'project',
            '/prd/:id': 'prd'
        },
        init: function() {
            $.jps.trigger('init', {
                projectId: null,
                prdId: null
            });
        },
        project: function(id) {
            $.jps.trigger('init', {
                projectId: id,
                prdId: null
            });
        },
        prd: function(id) {
            prd.getPrd(id, function(prdDate) {
                if (prdDate && prdDate.length) {
                    var item = prdDate[0];
                    $.jps.trigger('init', {
                        prdId: id,
                        projectId: item.projectId,
                        prd: item
                    });
                }
            });
            
        }
    });

    router.start();
})(jQuery);